package com.gitee.alpha.ie.handler;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;

/**
 * 冻结窗格<br>
 *
 * @author 冰羽
 * @version 2.2.0
 */
public class FreezePaneHandler implements SheetWriteHandler {
  /** Horizonatal position of split. */
  private int colSplit;

  /** Vertical position of split. */
  private int rowSplit;
  /** Left column visible in right pane. */
  private int leftmostColumn;

  /** Top row visible in bottom pane */
  private int topRow;

  public FreezePaneHandler(int colSplit, int rowSplit, int leftmostColumn, int topRow) {
    this.colSplit = colSplit;
    this.rowSplit = rowSplit;
    this.leftmostColumn = leftmostColumn;
    this.topRow = topRow;
  }

  @Override
  public void beforeSheetCreate(
      WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {}

  @Override
  public void afterSheetCreate(
      WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
    writeSheetHolder.getSheet().createFreezePane(colSplit, rowSplit, leftmostColumn, topRow);
  }
}
